package com.android.jixin.channel.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.android.jixin.channel.R;
import com.android.jixin.channel.base.BaseActivity;
import com.android.jixin.channel.presenter.impl.RegisterPresenterImpl;
import com.android.jixin.channel.view.IRegisterView;
import com.rengwuxian.materialedittext.MaterialEditText;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnTextChanged;

public class RegisterActivity extends BaseActivity<RegisterPresenterImpl> implements IRegisterView{

    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.phone)
    MaterialEditText phone;
    @BindView(R.id.code)
    MaterialEditText code;
    @BindView(R.id.next)
    TextView next;

    @Override
    protected void initView() {
        next.setEnabled(false);
        title.setText(getString(R.string.register_title));
    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_register;
    }

    @Override
    protected void initInjector() {
        getActivityComponent().inject(this);
    }

    @OnTextChanged(R.id.phone)
    void onhoneChanged(CharSequence text){
        mPresenter.setEnable(phone.getText().toString(), code.getText().toString());
    }
    @OnTextChanged(R.id.code)
    void onCodeChanged(CharSequence text){
        mPresenter.setEnable(phone.getText().toString(), code.getText().toString());
    }

    @Override
    public void setLoginEnable(boolean enable) {
        next.setEnabled(enable);
    }

    @OnClick({R.id.getcode, R.id.next, R.id.protocol})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.getcode:
                break;
            case R.id.next:
                readyGo(RegisterSuccessActivity.class);
                break;
            case R.id.protocol:
                break;
        }
    }
}
